use QcCore::ecs::component::Component;
use QcScript::core::JsComponent;

use super::{ComponentState, InspectorContext, InspectorTrait};

pub mod camera;
pub mod js_component;
pub mod light;
pub mod material_render;
pub mod mesh_render;
pub mod skybox;
pub mod transform;

impl InspectorTrait for Component {
    fn inspector(&mut self, ctx: &mut InspectorContext, state: &mut ComponentState) {
        match self {
            Component::Camera(comp) => {
                comp.inspector(ctx, state);
            }
            Component::Light(comp) => comp.inspector(ctx, state),
            Component::MaterialRender(comp) => {
                comp.inspector(ctx, state);
            }
            Component::MeshRender(comp) => {
                comp.inspector(ctx, state);
            }
            Component::SkyBox(comp) => {
                comp.inspector(ctx, state);
            }
            Component::Transform(comp) => {
                comp.inspector(ctx, state);
            }
            Component::Other(comp) => {
                if let Some(comp) = comp.asAnyMut().downcast_mut::<JsComponent>() {
                    comp.inspector(ctx, state);
                }
            }
            Component::PointLight(comp) => comp.inspector(ctx, state),
            Component::AmbientBoxLight(comp) => comp.inspector(ctx, state),
            Component::AmbientSphereLight(comp) => comp.inspector(ctx, state),
            Component::SpotLight(comp) => comp.inspector(ctx, state),
            Component::DirectionalLight(comp) => comp.inspector(ctx, state),
        }
    }
}
